package com.java.basis.collection;

import java.util.Enumeration;
import java.util.Vector;

/**
 * 演示Vector的使用
 * 存储结构：数组
 * @author wangning
 * @create 2021-04-10 22:12
 */
public class TestVector01 {
	public static void main(String[] args) {
		//创建集合
		Vector vector = new Vector<>();
		//1.添加元素
		vector.add("草莓");
		vector.add("芒果");
		vector.add("西瓜");
		System.out.println("vector.size() = " + vector.size());
		//2.删除
//		vector.remove(0);
//		vector.remove("西瓜");
//		vector.clear();
		//3.遍历
		//使用枚举器
		Enumeration elements = vector.elements();
		while (elements.hasMoreElements()) {
			String o = (String) elements.nextElement();
			System.out.println("o = " + o);
		}
		//4.判断
		System.out.println(vector.isEmpty());
		System.out.println(vector.contains("西瓜"));
		//5.vector其它方法
		//firstElement，lastElement，elementAt()

	}
}
